package jym.tan.tmdb.method.get;

import java.net.URL;

import jym.tan.tmdb.TMDB;
import jym.tan.tmdb.bean.wrapper.MovieTrailerWrapper;
import jym.tan.tmdb.constant.TMDBConstants;
import jym.tan.tmdb.method.Base;

/**
 * The Class MovieTrailers. This class is similar to the <b>Movie Trailers</b> method described in 
 * <a href="http://help.themoviedb.org/kb/api/movie-trailers">Movie Trailers</a>.
 * This method is used to retrieve all of the trailers for a particular movie. Supported sites are YouTube and QuickTime.
 * @author Tanmoy
 */
public class MovieTrailers extends Base {

	/**
	 * Instantiates a new MovieTrailers.
	 *
	 * @param tmdb 
	 * 		An instance of the {@link TMDB} class
	 */
	public MovieTrailers(TMDB tmdb) {
		super(tmdb, TMDBConstants.MOVIE, TMDBConstants.TRAILERS);
	}

	/**
	 * Gets a {@link MovieTrailerWrapper} object.
	 *
	 * @param movieId 
	 * 		The TMDB id / the IMDB id
	 * @param language 
	 * 		The language parameter tries to localize the movie data we return. If the 
	 * 		language being requested does not exist, the value will be left blank. 
	 * 		The expected value is a ISO 639-1 code
	 * @return 
	 * 		The <code>MovieTrailerWrapper</code> object
	 * @throws Exception 
	 * 		If any kind off exception occurred
	 */
	public MovieTrailerWrapper getMovieTrailerWrapper(String movieId, String language) throws Exception {
		URL movieTrailerURL = getUrl(movieId, language);
		MovieTrailerWrapper movieTrailerWrapper = getJsonObject(movieTrailerURL, MovieTrailerWrapper.class);
		return movieTrailerWrapper;		
	}
}
